#include <iostream>
#include <stdio.h>

class csum
{
	public:
	virtual int add(int a, int b)
	{
		printf("csum a + b.\n");
		return (a + b);
	}

	virtual int sub(int a, int b)
	{
		printf("csum a - b.\n");
		return (a - b);
	}
};

int main()
{
	csum *pcsum = new csum;

	pcsum->add(1, 2);
	pcsum->sub(3, 1);

	delete pcsum;

	return 0;
}

/*
csum a + b.
csum a - b.
 */

#if 0

/*
 * intel
 */
00000000000011c9 <main>:
    11c9:	f3 0f 1e fa          	endbr64 
    11cd:	55                   	push   %rbp
    11ce:	48 89 e5             	mov    %rsp,%rbp
    11d1:	53                   	push   %rbx
    11d2:	48 83 ec 18          	sub    $0x18,%rsp	// rsp-=0x18
    11d6:	bf 08 00 00 00       	mov    $0x8,%edi	// edi=0x8
    11db:	e8 c0 fe ff ff       	callq  10a0 <_Znwm@plt>	// new(8)
    11e0:	48 89 c3             	mov    %rax,%rbx	// rbx=rax
    11e3:	48 89 df             	mov    %rbx,%rdi	// rdi=rbx
    11e6:	e8 21 01 00 00       	callq  130c <_ZN4csumC1Ev>	// csum()
    11eb:	48 89 5d e8          	mov    %rbx,-0x18(%rbp)	// (rbp-0x18)=rbx
    11ef:	48 8b 45 e8          	mov    -0x18(%rbp),%rax	// rax=(rbp-0x18)
    11f3:	48 8b 00             	mov    (%rax),%rax	// rax=(rax)
    11f6:	48 8b 08             	mov    (%rax),%rcx	// rcx=(rax)
    11f9:	48 8b 45 e8          	mov    -0x18(%rbp),%rax	// rax=(rbp-0x18)
    11fd:	ba 02 00 00 00       	mov    $0x2,%edx	// edx=2
    1202:	be 01 00 00 00       	mov    $0x1,%esi	// esi=1
    1207:	48 89 c7             	mov    %rax,%rdi	// rdi=rax
    120a:	ff d1                	callq  *%rcx		// rcx()
    120c:	48 8b 45 e8          	mov    -0x18(%rbp),%rax	// rax=(rbp-0x18)
    1210:	48 8b 00             	mov    (%rax),%rax	// rax=(rax)
    1213:	48 83 c0 08          	add    $0x8,%rax	// rax+=0x8
    1217:	48 8b 08             	mov    (%rax),%rcx	// rcx=(rax)
    121a:	48 8b 45 e8          	mov    -0x18(%rbp),%rax	// rax=(rbp-0x18)
    121e:	ba 01 00 00 00       	mov    $0x1,%edx	// edx=1
    1223:	be 03 00 00 00       	mov    $0x3,%esi	// esi=3
    1228:	48 89 c7             	mov    %rax,%rdi	// rdi=rax
    122b:	ff d1                	callq  *%rcx		// rcx()
    122d:	48 8b 45 e8          	mov    -0x18(%rbp),%rax	// rax=(rbp-0x18)
    1231:	48 85 c0             	test   %rax,%rax	// rax&rax
    1234:	74 0d                	je     1243 <main+0x7a>	// ==
    1236:	be 08 00 00 00       	mov    $0x8,%esi	// esi=0x8
    123b:	48 89 c7             	mov    %rax,%rdi	// rdi=rax
    123e:	e8 6d fe ff ff       	callq  10b0 <_ZdlPvm@plt>
    1243:	b8 00 00 00 00       	mov    $0x0,%eax	// eax=0
    1248:	48 83 c4 18          	add    $0x18,%rsp	// rsp+=0x18
    124c:	5b                   	pop    %rbx
    124d:	5d                   	pop    %rbp
    124e:	c3                   	retq   

00000000000012b6 <_ZN4csum3addEii>:
    12b6:	f3 0f 1e fa          	endbr64 
    12ba:	55                   	push   %rbp
    12bb:	48 89 e5             	mov    %rsp,%rbp
    12be:	48 83 ec 10          	sub    $0x10,%rsp
    12c2:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)	// (rbp-0x8)=rdi
    12c6:	89 75 f4             	mov    %esi,-0xc(%rbp)	// (rbp-0xc)=esi
    12c9:	89 55 f0             	mov    %edx,-0x10(%rbp)	// (rbp-0x10)=edx
    12cc:	48 8d 3d 32 0d 00 00 	lea    0xd32(%rip),%rdi        # 2005 <_ZStL19piecewise_construct+0x1>
    12d3:	e8 f8 fd ff ff       	callq  10d0 <puts@plt>	// puts()
    12d8:	8b 55 f4             	mov    -0xc(%rbp),%edx	// edx=(rbp-0xc)
    12db:	8b 45 f0             	mov    -0x10(%rbp),%eax	// eax=(rbp-0x10)
    12de:	01 d0                	add    %edx,%eax	// eax+=edx
    12e0:	c9                   	leaveq 
    12e1:	c3                   	retq   

00000000000012e2 <_ZN4csum3subEii>:
    12e2:	f3 0f 1e fa          	endbr64 
    12e6:	55                   	push   %rbp
    12e7:	48 89 e5             	mov    %rsp,%rbp
    12ea:	48 83 ec 10          	sub    $0x10,%rsp
    12ee:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)	// (rbp-0x8)=rdi
    12f2:	89 75 f4             	mov    %esi,-0xc(%rbp)	// (rbp-0xc)=esi
    12f5:	89 55 f0             	mov    %edx,-0x10(%rbp)	// (rbp-0x10)=edx
    12f8:	48 8d 3d 12 0d 00 00 	lea    0xd12(%rip),%rdi        # 2011 <_ZStL19piecewise_construct+0xd>
    12ff:	e8 cc fd ff ff       	callq  10d0 <puts@plt>	// puts()
    1304:	8b 45 f4             	mov    -0xc(%rbp),%eax	// eax=(rbp-0xc)
    1307:	2b 45 f0             	sub    -0x10(%rbp),%eax	// eax=(rpb-0x10)
    130a:	c9                   	leaveq 
    130b:	c3                   	retq   

000000000000130c <_ZN4csumC1Ev>:
    130c:	f3 0f 1e fa          	endbr64 
    1310:	55                   	push   %rbp
    1311:	48 89 e5             	mov    %rsp,%rbp
    1314:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)	// (rbp-0x8)=rdi
    1318:	48 8d 15 51 2a 00 00 	lea    0x2a51(%rip),%rdx        # 3d70 <_ZTV4csum+0x10>
    131f:	48 8b 45 f8          	mov    -0x8(%rbp),%rax	// rax=(rbp-0x8)
    1323:	48 89 10             	mov    %rdx,(%rax)	// (rax)=rdx
    1326:	90                   	nop
    1327:	5d                   	pop    %rbp
    1328:	c3                   	retq   
    1329:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)

/*
 * arm
 */
000000000040089c <main>:
  40089c:	a9bd7bfd 	stp	x29, x30, [sp, #-48]!
  4008a0:	910003fd 	mov	x29, sp
  4008a4:	f9000bf3 	str	x19, [sp, #16]		// [sp+16]=x19
  4008a8:	d2800100 	mov	x0, #0x8                   	// #8
  4008ac:	97ffffb9 	bl	400790 <_Znwm@plt>	// new(8)
  4008b0:	aa0003f3 	mov	x19, x0			// x19=x0
  4008b4:	aa1303e0 	mov	x0, x19			// x0=x19
  4008b8:	94000051 	bl	4009fc <_ZN4csumC1Ev>	// csun()
  4008bc:	f90017b3 	str	x19, [x29, #40]		// [x29+40]=x19
  4008c0:	f94017a0 	ldr	x0, [x29, #40]		// x0=[x29+40]
  4008c4:	f9400000 	ldr	x0, [x0]	// x0=[x0]
  4008c8:	f9400003 	ldr	x3, [x0]	// x3=[x0]
  4008cc:	52800042 	mov	w2, #0x2                   	// #2
  4008d0:	52800021 	mov	w1, #0x1                   	// #1
  4008d4:	f94017a0 	ldr	x0, [x29, #40]	// x0=[x29+40]
  4008d8:	d63f0060 	blr	x3		// x3
  4008dc:	f94017a0 	ldr	x0, [x29, #40]	// x0=[x29+40]
  4008e0:	f9400000 	ldr	x0, [x0]	// x0=[x0]
  4008e4:	91002000 	add	x0, x0, #0x8	// x0=x0+8
  4008e8:	f9400003 	ldr	x3, [x0]	// x3=[x0]
  4008ec:	52800022 	mov	w2, #0x1                   	// #1
  4008f0:	52800061 	mov	w1, #0x3                   	// #3
  4008f4:	f94017a0 	ldr	x0, [x29, #40]
  4008f8:	d63f0060 	blr	x3		// jump
  4008fc:	d2800101 	mov	x1, #0x8                   	// #8
  400900:	f94017a0 	ldr	x0, [x29, #40]	// x0=[x29+40]
  400904:	97ffff8b 	bl	400730 <_ZdlPvm@plt>
  400908:	52800000 	mov	w0, #0x0                   	// #0
  40090c:	f9400bf3 	ldr	x19, [sp, #16]
  400910:	a8c37bfd 	ldp	x29, x30, [sp], #48
  400914:	d65f03c0 	ret

0000000000400994 <_ZN4csum3addEii>:
  400994:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  400998:	910003fd 	mov	x29, sp
  40099c:	f9000fa0 	str	x0, [x29, #24]	// [x29+24]=x0
  4009a0:	b90017a1 	str	w1, [x29, #20]	// [x29+20]=w1
  4009a4:	b90013a2 	str	w2, [x29, #16]	// [x29+16]=w2
  4009a8:	90000000 	adrp	x0, 400000 <_init-0x6d0>
  4009ac:	912b6000 	add	x0, x0, #0xad8	// x0=400ad8
  4009b0:	97ffff74 	bl	400780 <puts@plt>	// puts()
  4009b4:	b94017a1 	ldr	w1, [x29, #20]	// w1=[x29+20]
  4009b8:	b94013a0 	ldr	w0, [x29, #16]	// w0=[x29+16]
  4009bc:	0b000020 	add	w0, w1, w0	// w0=w1+w0
  4009c0:	a8c27bfd 	ldp	x29, x30, [sp], #32
  4009c4:	d65f03c0 	ret

00000000004009c8 <_ZN4csum3subEii>:
  4009c8:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  4009cc:	910003fd 	mov	x29, sp
  4009d0:	f9000fa0 	str	x0, [x29, #24]	// [x29+24]=x0
  4009d4:	b90017a1 	str	w1, [x29, #20]	// [x29+20]=w1
  4009d8:	b90013a2 	str	w2, [x29, #16]	// [x29+16]=w2
  4009dc:	90000000 	adrp	x0, 400000 <_init-0x6d0>
  4009e0:	912ba000 	add	x0, x0, #0xae8	// 400ae8
  4009e4:	97ffff67 	bl	400780 <puts@plt> // puts()
  4009e8:	b94017a1 	ldr	w1, [x29, #20]	// w1=[x29+20]
  4009ec:	b94013a0 	ldr	w0, [x29, #16]	// w0=[x29+16]
  4009f0:	4b000020 	sub	w0, w1, w0	// w0=w1-w0
  4009f4:	a8c27bfd 	ldp	x29, x30, [sp], #32
  4009f8:	d65f03c0 	ret

00000000004009fc <_ZN4csumC1Ev>:
  4009fc:	d10043ff 	sub	sp, sp, #0x10
  400a00:	f90007e0 	str	x0, [sp, #8]	// [sp+8]=x0
  400a04:	90000000 	adrp	x0, 400000 <_init-0x6d0>
  400a08:	912c2001 	add	x1, x0, #0xb08	// x1=400b08
  400a0c:	f94007e0 	ldr	x0, [sp, #8]	// x0=[sp+8]
  400a10:	f9000001 	str	x1, [x0]	// [x0]=x1
  400a14:	d503201f 	nop
  400a18:	910043ff 	add	sp, sp, #0x10
  400a1c:	d65f03c0 	ret

#endif
